﻿#ifndef MYDB_H
#define MYDB_H

#include <string>
#include <mysql/mysql.h>

using namespace std;

#define HOST "139.224.247.174"
#define USER "root"
#define PWD "123456"
#define DBNAME "shop"
#define PORT 3306

class MyDB {
  public:
    ~MyDB();
    static MyDB *getDB() {
        static MyDB myDB;
        return &myDB;
    }
    bool InitDB(const char *host, const char *user, const char *pwd, const char *dbname, int port);
    string *selectData(string *sql, string *resultStr);  // 查
    bool updateData(string *sql);     // 增删改
  private:
    MyDB();
    MYSQL* mysql;  // 连接对象
};

#endif // MYDB_H
